package com.yuan.springcloud.user.bean.vo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.Version;
import com.yuan.springcloud.common.db.bean.Entity;
import com.yuan.springcloud.common.web.bean.VO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.*;

/**
 * @author YouYuan
 * @date 2020/8/15 21:27
 */
@EqualsAndHashCode(callSuper = true)
@ApiModel(description = "用户数据返回类")
@Data
public class UserVO extends VO {

    @ApiModelProperty(value = "用户ID", example = "1")
    @NotNull(message = "用户ID不能为空")
    private Long id;

    @ApiModelProperty(value = "用户名", example = "YouYuan")
    @NotEmpty(message = "用户名不能为空")
    @Pattern(regexp = "^[a-zA-Z0-9]{5,16}$", message = "用户名只能包含字母和数字")
    @Length(min = 5, max = 16, message = "用户名长度不能小于5超出16")
    private String username;

    @ApiModelProperty(value = "昵称", example = "友缘")
    @NotEmpty(message = "昵称不能为空")
    private String nickname;

    @ApiModelProperty(value = "邮箱", example = "xiyousuiyuan@163.com")
    @Pattern(regexp = "^[a-zA-Z0-9-_]+@[a-zA-Z0-9-_]+.[a-zA-Z]{2,}$", message = "邮箱格式不正确")
    @Length(min = 3, max = 140, message = "email长度不能小于3超出140")
    private String email;

    @ApiModelProperty(value = "手机号", example = "17000000000")
    @Pattern(regexp = "^(\\+\\d{2})?(1\\d{10})", message = "手机号格式不正确")
    private String mobile;

    @ApiModelProperty(value = "用户类型", example = "0")
    @Min(value = 0, message = "userType不能小于0")
    @Max(value = 5, message = "userType不能大于5")
    private Integer userType;

    @ApiModelProperty(value = "启用状态(0:启用,1:禁用)", example = "1")
    @Range(min = 0, max = 1, message = "启用状态(0:启用,1:禁用)")
    private Integer isEnable;

    @ApiModelProperty(value = "版本号", example = "1")
    @Version
    @NotNull(message = "version参数缺失")
    @Min(value = 0, message = "version不能小于0")
    private Integer version;

}
